package com.xhs.dto.response;

import com.xhs.entity.Content;
import lombok.Data;

import java.time.LocalDateTime;

/**
 * 内容响应DTO
 */
@Data
public class ContentResponse {
    private Long id;
    private String title;
    private String description;
    private String type;
    private String fileUrl;
    private String thumbnailUrl;
    private Long fileSize;
    private String mimeType;
    private Integer duration;
    private String tags;
    private Integer likeCount;
    private Integer commentCount;
    private Integer viewCount;
    private Boolean published;
    private String authorName;
    private Long authorId;
    private LocalDateTime createdAt;
    private LocalDateTime updatedAt;
    
    public static ContentResponse fromEntity(Content content) {
        ContentResponse response = new ContentResponse();
        response.setId(content.getId());
        response.setTitle(content.getTitle());
        response.setDescription(content.getDescription());
        response.setType(content.getType().name());
        response.setFileUrl(content.getFileUrl());
        response.setThumbnailUrl(content.getThumbnailUrl());
        response.setFileSize(content.getFileSize());
        response.setMimeType(content.getMimeType());
        response.setDuration(content.getDuration());
        response.setTags(content.getTags());
        response.setLikeCount(content.getLikeCount());
        response.setCommentCount(content.getCommentCount());
        response.setViewCount(content.getViewCount());
        response.setPublished(content.getPublished());
        response.setAuthorName(content.getAuthor().getUsername());
        response.setAuthorId(content.getAuthor().getId());
        response.setCreatedAt(content.getCreatedAt());
        response.setUpdatedAt(content.getUpdatedAt());
        return response;
    }
} 